<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed'); 
	
function formError($msg = ''){
	$err = array(
				'error'=>true,
				'error_msg'=> $msg, 
	);	
	return json_encode($err);
}

function formObjects($index = ''){
	$objects = array(
		'signup' => array(
			'name' => array(
						'id'	=>	'name',
						'name'	=>	'name',
						'class' => 	'required',
						'value' => set_value('name')
						),
			'email' => array(
						'id'	=>	'email',
						'name'	=>	'email',
						'class' => 'required email',
						'value' => set_value('email')
						),
			'password' => array(
						'id'	=>	'password',
						'name'	=>	'password',
						'class' => 'required',
						'minlength' => '8',
						'value' => set_value('password')
						),
			
			'password2' => array(
						'id'	=>	'password2',
						'name'	=>	'password2',
						'class' => 'required',
						'minlength' => '8',
						'value' => set_value('password2')
						),
			'registerbtn' => array(
						'id'	=>	'registerbtn',
						'name'	=>	'registerbtn',
						'class'	=>	'btn btn-primary',
						'value'	=>	'Sign Up'
			),
			'reset' => array(
						'name'	=>	'login',
						'class'	=>	'btn',
						'value'	=>	'Clear'
						)
		),
		'login' => array(
			'email' => array(
						'id'	=>	'email',
						'name'	=>	'email',
						'class' => 'required email',
						'value' => set_value('email'),
						'placeholder' => 'email address'
						),
			'password' => array(
						'id'	=>	'password',
						'name'	=>	'password',
						'class' => 'required',
						'minlength' => '8',
						'value' => set_value('password'),
						'placeholder' => 'password'
						),
			'loginbtn' => array(
						'id'	=>	'loginbtn',
						'name'	=>	'loginbtn',
						'class'	=>	'btn btn-primary',
						'value'	=>	'Sign In'
						)

		),
                'post'  =>  array(
                        'postbox' => array(
                                                'id'	=>	'postbox',
                                                'name'	=>	'postbox',
                                                'class' =>      'postbox input-xlarge',
                                                'rows'	=>      '5',
                                                'cols'	=>      '200',
                                                'value' =>      set_value('comment'),
                                                'style'	=>      'width:790px;',
                                                'placeholder' => 'type a new comment here..'
                                                ),
                         'postbtn' => array(
                                                'id'	=>	'postbtn',
                                                'name'	=>	'postbtn',
                                                'class'	=>	'btn btn-primary',
                                                'value'	=>	'Post'
                                            )
                    )
	);
	$objects = (isset($index) && !empty($index)) ? $objects[$index] : $objects; 
	return $objects;
}